package com.eastcom.bm.datamonitorsupplement.task;

import java.sql.ResultSet;
import java.util.Date;

import com.eastcom.bm.atom.Atom_DatasetDefine;
import com.eastcom.bm.datamonitorsupplement.MonitorMain;
import com.eastcom.canicula.stope.utils.MyLogger;
import com.eastcom.providor.dao.impl.DataAbnormalDao;
import com.eastcom.providor.dao.impl.DataSetDao;
import com.eastcom.providor.util.DataSetKit;
import com.eastcom.providor.util.MessageAssembler;

public abstract class AbnormalProcessor {

	public DataAbnormalDao dataAbnormalDao;
	public DataSetDao dataSetDao;
	
	public AbnormalProcessor(DataAbnormalDao dataAbnormalDao,DataSetDao dataSetDao){
		this.dataAbnormalDao=dataAbnormalDao;
		this.dataSetDao=dataSetDao;
	}
	public abstract void process(String dataset_id,Date start,Date end) throws Exception;
	
	protected synchronized void queryAndSend(Atom_DatasetDefine datasetDefine, String allSql) {
		ResultSet rs=DataSetKit.executeSqlQueryFromSource(allSql, datasetDefine);
		String message=MessageAssembler.RSToMessage(rs, datasetDefine.getId());
		if(message!=null&&!message.equals("")){
			MyLogger.logger.info(message);
			send(message);
		}
	}
	
	public abstract void send(String message);
}
